home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
c
/
natcomp.zip
/
NAT.CB
< prev
Wrap
Text File
|
1990-02-23
|
3KB
|
132 lines
/* _init macro.
* Do not change this macro (always overwritten by Setup
*/
_init()
{
extern autosave, /* External macro declarations */
toggle_re;
color( 7, 0, 1, 1, 4, 0x80 ); /* Set the screen colors */
autosave(); /* Automatic file save when idle */
}
/* Initials macro.
* Use this macro for additional customization.
*/
#include <nat.h>
NAT()
{
load_macro( "file_ed5" );
autoload( "ascii", "ascii" );
assign_to_key( "<Ctrl-a>", "ascii" );
autoload( "diff", "diff" );
assign_to_key( "<Ctrl-d>", "diff" );
autoload( "calc", "calc" );
assign_to_key( "<Alt-F1>", "calc" );
load_macro( "rat" );
/* key assignments are made in rat.cb _init macro:
* crtl-L = left mouse button
* crtl-R = right mouse button These must agree w/ mouse.def
* ctrl-B = both mouse buttons mouse menu driver
*/
autoload( "whichkey", "whichkey" );
assign_to_key( "<Ctrl-k>", "whichkey" );
autoload( "freekey", "freekey" );
autoload( "dir", "dir" );
assign_to_key( "<Ctrl-F1>", "dir" );
autoload( "ctags", "ctag" );
assign_to_key( "<Ctrl-F10>", "ctag" );
autoload( "switcase", "switcase" );
autoload( "grep", "grep" );
autoload( "grep_r", "grep_r" );
autoload( "outline", "outline" );
autoload( "linedraw", "linedraw" );
return;
}
/* File Extension Macros, etc.
* macros marked "overwritable" may be overwritten by setup.
*/
/* Overwritable by Setup */
default (...)
{
tabs (4, 7);
}
/* read_word:
*
* Reads one alphanumeric word starting at current position.
* Returns the ascii string read from the word itself.
* Srch_code is a code that determines what type of "word" to search for.
* 0 = non whitespace word
* 1 = alphanumeric word
* 2 = variable string (C-syntax)
*/
string read_word( int srch_code ) /* reads next word, position moves past the end of word */
{
string srch_str, nxtc, word = "";
switch( srch_code )
{
case 0:
srch_str = WHTSPC;
case 1:
srch_str = _ALPHNUM;
case 2:
srch_str = _VARNAM;
default:
error("Error: read_word: %d not a valid search code");
}
search_back (srch_str); /* get to the start of the word I'm in */
search_fwd (srch_str);
next_char();
nxtc = read(1);
while( !search_string( srch_str, nxtc ) )
{
word += nxtc;
next_char();
nxtc = read(1);
}
return( word );
}
string trans_envar( string cmdln ) /* NAT -- added 1/14/90 */
{ /* transl %VAR% to ascii string */
int pos, len;
string cmdln0 = cmdln, /* made into a recursive call */
new_cmdln = "", /* so env vars may have env vars */
envstr;
while( pos = search_string( "[%][A-Za-z0-9_]+[%]", cmdln0, len ) )
{
new_cmdln += substr( cmdln0, 1, pos-1 );
envstr = substr( cmdln0, pos+1, len-2 ); /* don't include %'s */
new_cmdln += inq_environment( envstr ); /* trans and append */
cmdln0 = substr( cmdln0, pos+len+1 ); /* move past env var */
}
if( search_string( "[%][A-Za-z0-9_]+[%]", new_cmdln, len ) )
new_cmdln = trans_envar( new_cmdln );
return trim( ltrim( new_cmdln + " " + cmdln0 ) );
}